<template>
  <div>
      添加权限：<select v-model="auth_id">

            <!-- [[1, "用户中心"], [2, "修改密码"], [3, "上传头像"]] -->

            <!-- <option :value="x[0]" v-for="x in auth_list">
                {{x[1]}}
            </option> -->

            <option :value="auth.id" v-for="(auth,index) in auth_list" :key="index">
                {{auth.auth_name}}
            </option>

      </select>
      <br />
      <van-button type="primary" @click="submit">确认</van-button>
  </div>
</template>

<script>
export default {
    data() {
        return {
            auth_list:[],
            auth_id:'',
            uid:localStorage.getItem('uid')
        }
    },

    mounted:function(){
        this.axios.get('http://localhost:8000/getuseraccess/').then(res=>{
            console.log(res.data)
            this.auth_list = res.data
        })
    },

    methods:{
        submit(){
            console.log(this.auth_id)
            this.axios.post('http://localhost:8000/getuseraccess/',this.qs.stringify({'uid':this.uid,
            'auth_id':this.auth_id})).then(res=>{
                console.log(res.data)
                if (res.data == 'ok'){
                    this.$toast('权限添加成功')
                }
            })

        }
    }
}
</script>

<style>


</style>